home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / Demos / Herois / Codigo.Cst / 00027_Script_Fundo Sonoro < prev    next >
Text File  |  1999-03-19  |  2KB  |  81 lines

  1. property memSom
  2. property ligado
  3. property tempoIn
  4. property minTocando, maxTocando
  5. property memoria, limitado
  6.  
  7. on getBehaviorDescription
  8.   return "Faz busca automatica de palavra clicada"
  9. end
  10.  
  11. on getPropertyDescriptionList
  12.   set p_list = [ ¼
  13.     #memSom: [ #comment:   "Membro que contem som",¼
  14.                  #format:   #string, ¼
  15.                  #default:    "MembroSom" ],¼
  16.     #tempoIn: [ #comment:   "Tempo de fadeIn",¼
  17.                  #format:   #integer, ¼
  18.                  #default:  120 ],¼
  19.     #minTocando: [ #comment:   "Tempo minimo que o som fica tocando",¼
  20.                  #format:   #integer, ¼
  21.                  #default:     300],¼
  22.     #maxTocando: [ #comment:   "Tempo maximo que o som fica tocando",¼
  23.                  #format:   #integer, ¼
  24.                  #default:  800 ],¼
  25.     #memoria: [ #comment:   "Memoria minima para tocar este som",¼
  26.                  #format:   #integer, ¼
  27.                  #default:  0 ]¼
  28.   ]
  29.   return p_list
  30. end
  31.  
  32. on beginSprite me
  33.   global myMemSize
  34.   if memoria * 1024 * 1024 > myMemSize then
  35.     set limitado = true
  36.   else 
  37.     set limitado = false
  38.     set ligado = false
  39.     if the number of member memSom <> -1 then
  40.       preloadMember member memSom
  41.     end if
  42.   end if
  43. end
  44.  
  45. on cleanSprite me
  46.   if (not limitado) and ligado then
  47.     global gFundoTempo
  48.     sound fadeOut 1, tempoIn
  49.     set gFundoTempo = the timer + tempoIn + 30
  50.     set ligado = false
  51.   end if
  52. end
  53.  
  54. on idleSprite me
  55.   if limitado then return
  56.   global gMustUpdate
  57.   global gFundoTempo  
  58.   if ligado then
  59.     if the timer >= gFundoTempo then
  60.       if soundBusy(1) then sound fadeOut 1, tempoIn
  61.       set gMustUpdate to true
  62.       set ligado = false
  63.       set gFundoTempo = the timer + tempoIn + random(maxTocando - minTocando) + minTocando
  64.     end if
  65.     
  66.   else -- Som desligado, espera o tempo para religar
  67.     if the timer >= gFundoTempo then
  68.       set gMustUpdate to true
  69.       puppetSound 1,  0
  70.       updateStage
  71.       set the volume of sound 1 to 255
  72.       updateStage
  73.       if the number of member memSom <> -1 then
  74.         puppetSound 1, memSom
  75.       end if
  76.       sound fadeIn 1, tempoIn
  77.       set ligado = true
  78.       set gFundoTempo = the timer + random(maxTocando - minTocando) + minTocando
  79.     end if
  80.   end if
  81. end